import router from './router'
import { getToken } from './utils/auth'
// import { TOKEN_KEY } from '@/constants/KEY'

const WETIE_LIST = ['/login', '/404']
router.beforeEach((to, from, next) => {
  const token = getToken()
  // console.log(token)
  // 有token
  if (token) {
    next()
  } else {
    // 没有token
    if (WETIE_LIST.includes(to.path)) {
      next()
    } else {
      next('/login')
    }
  }
})
